/* Copyright (c) 2025 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#ifndef __CERTIFICATE_H__
#define __CERTIFICATE_H__

#include "library/spdm_crypt_lib.h"
#include "common.h"

#ifdef G_ENABLE_TEST
#define SHM_TMP_CERT_FOLDER "tmp/cert/spdm"
#else
#define SHM_TMP_CERT_FOLDER "/dev/shm/tmp/cert/spdm"
#endif // G_ENABLE_TEST

class Certificate {
public:
    uint8_t          digest[LIBSPDM_MAX_HASH_SIZE] = {0};
    uint32_t         certificateType;
    uint32_t         certificateUsageType;
    string           fingerPrint;
    string           fingerPrintHashAlgorithm;
    string           issuer;
    string           subject;
    uint32_t         keyUsage;
    string           keyUsageString;
    string           serialNumber;
    string           signatureAlgorithm;
    uint64_t         validNotBefore;
    uint64_t         validNotAfter;
    string           commonName;
    uint32_t         certCount;
    uint32_t         keyLength;
    string           publicKey;
    string           hashVal;

    Certificate() {};
    ~Certificate() = default;
    int32_t InitCertificateInfo(const vector<uint8_t>& der_data);
};

#endif // __CERTIFICATE_H__